function registerGrid(selector){
	Vue.component("grid", {
		template : selector,//"#grid-template",
		props : {
			data : Array,
			headers : Array,
			columns : Array,
			major : String,
			resc : String,
			rescName: String,
			buttons: Object,
			noSearch:Boolean
		},
		data : function() {
			var sortOrders = {};
			this.columns.forEach(function(key) {
				sortOrders[key] = 1;
			});
			
			var selected=[];
			for(var i=0,len=this.data.length;i<len;i++){
				selected[i]=false;
			}
			return {
				searchQuery:'',
				sortKey : '',
				sortOrders : sortOrders,
				search:!this.noSearch,
				selected:selected
			};
		},
		methods : {
			sortBy : function(key) {
				this.sortKey = key;
				this.sortOrders[key] = this.sortOrders[key] * -1;
			},
			showView:function(type,key){
				var _this=this;
				var options = {
			        url: "/backend/view?resc="+this.resc+"&type="+type+"&code="+key,
			        title:'提示对话框',
			        buttons:[]
			    };
				eModal.ajax(options).done(function(html){
					_this.viewLoaded(html,"gridUpdateSuccess",type);
				});
			},
			viewLoaded:function(html,eventName,type){
				logs("viewLoaded");
				var _this=this;
				var $form=$(html).find("form").first();
				$form.on("submit",function(){
					$form.ajaxSubmit({
		                success:function(resp){
		                	if(resp.errCode=='00'){
		                		_this.data=resp.items;
								_this.$nextTick(function () {
									logs("eventName:"+eventName);
									_this.$dispatch(eventName,resp,type);
								});
		                	}else{
		                		bootbox.alert(resp.message);
		                	}
		                },
		                error:function(){
		                	eModal.alert("提交失败");
		                }
		            });
					return false;
				});
			},
			rowSelected:function(code,index){
				var selected=[];
				for(var i=0,len=this.data.length;i<len;i++){
					selected[i]=(i==index);
				}
				this.selected=selected;
				this.$dispatch("rowSelected",code);
			}
		}
	});
}